/**
 * promise的3种状态
 * pending 进行中
 * fulfilled 已成功
 * rejected 已失败
 */

// 正常的promise
function promise(flag) {
    return new Promise((resolve, reject) => {
        setTimeout(() => {
            if (flag) {
                resolve('成功')
            } else {
                reject('失败')
            }
        }, 5000);
    })

    // return new myPromise((resolve, reject) => {
    //     if (flag) {
    //         resolve('成功')
    //     } else {
    //         reject('失败')
    //     }
    // })
}

promise(true).then((res) => {
    console.log(res)
}).catch((err) => {
    console.log(err)
}).finally(() => {
    console.log('end')
})

function myPromise(resolve, reject) {
    let status = 'pending';
    if (status === 'fulfilled') {
        return function() {
            
        }
    } else if (status === 'rejected') {

    } else {

    }
}
myPromise.prototype.then = function() {
    return new myPromise()
}
myPromise.prototype.catch = function() {
    
}
myPromise.prototype.finally = function() {
    
}

